package com.neusoft.crm.controller;


import com.neusoft.crm.entity.CommonResult;
import com.neusoft.crm.entity.Role;
import com.neusoft.crm.service.IRoleService;
import com.neusoft.crm.service.ISysinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 东软集团
 * @since 2023-04-03
 */
@RestController
@RequestMapping("/role")
@CrossOrigin
public class RoleController {
    @Autowired
    IRoleService roleService;

    @Autowired
    ISysinfoService sysinfoService;

    @GetMapping("/q/all")
    public CommonResult loadAll(){
        return   roleService.loadAll();
    }


    @GetMapping("/q/tree")
    public CommonResult loaddTree(){
        return   sysinfoService.tree();
    }


    @PostMapping("/mod")

    public   CommonResult modRole(@RequestBody Role role){
        return roleService.modRole(role);
    }

    @PutMapping("/add")

    public  CommonResult addRole(@RequestBody Role role){
        return roleService.addRole(role);
    }


    @GetMapping("/q/sysbyrolno/{roleno}")

    public CommonResult getSysByRoleno(@PathVariable String roleno ){
        return   roleService.getSysByRoleno(roleno);
    }




    @PostMapping("/modsys")
    public  CommonResult  modSys( String roleno, String [] sysnos ){

        return  roleService.modSys( roleno , sysnos );
    }
//    http://localhost:18080/role/q/syslistbyroleno/3

    @GetMapping("/q/syslistbyroleno/{roleno}")

    public CommonResult getSysListByRoleno(@PathVariable String roleno ){
        return   roleService.getSysListByRoleno(roleno);
    }




}
